package com.hzp.micromall.common.core.constant;

import java.util.Arrays;

/**
 * @Author houzipeng
 * @Date 2022/2/21 20:08
 * @Version 1.0
 * 服务名称
 */
public enum ServiceNameConstants {
    /**
     * 用户服务
     */
    USER(1L, "micromall-user"),
    /**
     * 商品服务
     */
    PRODUCT(1501041008530522113L, "micromall-product"),

    /**
     * 内容服务
     */
    CONTENT(1501206469297688577L, "micromall-content"),

    /**
     * 订单服务
     */
    ORDER(1501210425071505409L, "micromall-order");

    private Long categoryId;
    private String serviceName;

    ServiceNameConstants(Long categoryId, String serviceName) {
        this.categoryId = categoryId;
        this.serviceName = serviceName;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public static String getServiceUrlPrefix(Long categoryId) {
        ServiceNameConstants constants = Arrays.stream(ServiceNameConstants.values()).
                filter(item -> item.categoryId.equals(categoryId)).
                findFirst().
                get();
        return constants.serviceName;
    }
}

